[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
V_RANDOM()
Return a psuedo random number.
-------------------------------------------------------------------------------
Syntax
V_RANDOM( [<nLimit>], [<nSeed>] ) -> nRandomNumber
Arguments
<nLimit> is the highest value that V_RANDOM() will produce. The
results will be randomly distributed between 0 and <nLimit>. The
default is a numeric integer between 0 and 65535. <nLimit>
is a static value and so remembers its value from one call to the next
and, therefore, does not need to be passed more than once.
<nSeed> is a numeric value which will can be used to start a stream
of random numbers from a different value. See discussion below.
Returns
V_RANDOM() returns a psuedo random number between 0 and <nLimit>.
The result is a numeric integer.
Description
V_RANDOM() can be used to produce a psuedo random number from within
Clipper. "Psuedo" random refers to the fact that the stream of numbers
will always have the same random pattern when started at any given
<nSeed>. Therefore, it is best to seed the function once before
calling it to return a random number.
An example of a popular <nSeed> uses the system clock. This is
because the number of seconds that have passed since midnight is
usually random at any one invokation of this function.
Examples
LOCAL x
// Seed the random number generator to return values between 0 and 500
V_RANDOM( 500, seconds() )
// Print out some random numbers. The results from your machine
// should be different from the results posted below.
FOR x = 1 TO 5
QOUT( V_RANDOM() )
NEXT // Results: 183, 440,
See Also:
V_RETRIEVE()
V_POKE()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson